<?php
class Calendar extends CI_Controller {
public static function get_instance() {
		
	}

	function index() {
		if($this->session->userdata('is_logged_in'))
		{
			 
		}
		else 
			include_once('index.html');
	}
	
	function delete_calender(){
		if($this->session->userdata('is_logged_in')){
			if ($_POST["cal_id"]){
				$this->load->model('calendar_model');
				$result=$this->calendar_model->delete_cal_by_id(intval($_POST["cal_id"]));
				echo $result;
			}
		}
		else 
			include_once('index.html');
	}
	
	//根据post的时间类型返回对应的日程信息
	function show_marker(){
		if($this->session->userdata('is_logged_in')){
			$time_type=$_POST['time_type'];
			$this->load->model('calendar_model');
			//根据时间类型返回cal信息
			$result=$this->calendar_model->get_cal_by_time($time_type);
			header('Content-Type: text/xml');
			header("Cache-Control: no-cache, must-revalidate");
		
			echo '<?xml version="1.0" encoding="UTF-8"?>
				  <calendar>';
			$iter=1;
//			if(count($result)==0)
//			{
//				return;
//			} 
			foreach($result as $row){
			
				echo "<id>" . $row->id . "</id>";
				echo "<time>" . $row->cal_time . "</time>";
				echo "<title>" . $row->point_title . "</title>";
				echo "<addr>" . $row->point_addr . "</addr>";
				echo "<point_x>" . $row->point_x . "</point_x>";
				echo "<point_y>" . $row->point_y . "</point_y>";
				echo "<type>" . $row->type . "</type>";
			}
			
		
			echo "</calendar>";
		}
		else 
			include_once('index.html');
		
	}
	
}
